package com.situ.javase.day9;

import java.util.ArrayList;
import java.util.Scanner;

public class StudentManager {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		ArrayList<Student> list = new ArrayList<Student>();
		while (true) {
			System.out.println("请输入学生的id：");
			int id = scanner.nextInt();
			System.out.println("请输入学生的名字：");
			String name = scanner.next();
			System.out.println("请输入学生的年龄：");
			int age = scanner.nextInt();
			Student student = new Student(id, name, age);
			list.add(student);
			
			System.out.println("是不是退出：0退出");
			int quit = scanner.nextInt();
			if (quit == 0) {
				break;
			}
		}
		
		for (Student student : list) {
			System.out.println(student);
		}
		
		while (true) {
			System.out.println("----------------------");
			System.out.println("根据id查找输入：1");
			System.out.println("根据名字查找输入：2");
			System.out.println("根据年龄查找输入：3");
			System.out.println("根据班级查找输入：4");
			System.out.println("退出程序：0");
			System.out.println("----------------------");
			int type = scanner.nextInt();
			if (type == 0) {
				System.out.println("退出程序");
				break;
			}
			
			switch (type) {
			case 1:
				
				break;
			case 2:
				System.out.println("请输入要搜索的名字：");
				String searchName = scanner.next();
				boolean isSeachByNameFound = false;
				for (Student student : list) {
					if (searchName.equals(student.getName())) {
						isSeachByNameFound = true;
						System.out.println(student);
					}
				}
				if (isSeachByNameFound == false) {
					System.out.println("没有该姓名学生");
				}
				break;

			default:
				break;
			}
		}
		
	}
}
